﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace WpfControlLibrary.Converts
{
    /// <summary>
    /// 根据控件高度，调整背景部分的位置
    /// </summary>
    [ValueConversion(typeof(double),typeof(Thickness))]
    public class OnOffButtonMarginConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string param = parameter?.ToString();
            double source = (double)value;
            if (param == "Rectangle") 
            {
                return new Thickness(source/2,0,0,0);
            }
            else
            {
                return new Thickness(source,0,0,0);
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
